package com.peanut.boot.controller;

import com.peanut.boot.entiity.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * @className: com.peanut.boot.controller-> SutdyThemleaf
 * @description:  Themleaf 模板引擎学习
 * @author: chenhs
 * @createDate: 2021-09-26 21:26
 * @version: 1.0
 */
@Controller
public class StudyThemleafCotroller {

    @RequestMapping(value = "/studyThemleaf")
    public String studyThemleaf(Model model) {
        model.addAttribute("link","https://www.baidu.com");
        model.addAttribute("msg","你好哇 thelmeaf");
        return "holleThymeleaf";
    }
    /**
     * @title 登录页面
     * @description 方法注释
     * @author cehnhs
     * @param
     * @updateTime 2021/9/26 22:34
     * @return
     *
     *
     * "/","login"   都映射的到这里
     */
    @GetMapping(value = {"/","/login"})
    public String loginPage() {
        return "login";
    }
    /**
     * @title
     * @description 登录方法
     * @author cehnhs
     * @param
     * @updateTime 2021/9/26 22:40
     * @return
     */
    @PostMapping(value = "/login")
	public String name(HttpServletRequest request, User user) {
		request.getSession().setAttribute("user", user);
		if (user != null) {
			return "admin";
		} else {
			return "login";
		}
	
	}
    /**
     * 条状到；联系页面引入的页面
     * @Description
     * @author chenhs
     * @Date 2021/9/27
     * @return
	 *
     */
	@GetMapping (value = "/inmportPage")
	public String inmportPage( ) {
		return "/codeInmport/common";
		
	}
    @GetMapping (value = "/mybatisPulsUser")
    public String mybatisPulsUser( ) {
        return "/codeInmport/mybatisPulsUser";

    }

}
